<?php
 require_once("../includes/controller/initialize.php"); 

  
?>
<!Doctype html>

<html>
<head>
<title>Flowershop-index</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <link href="view/stylesheet/style.css" type="text/css" rel="stylesheet"/>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
 

  <script>
      $(function() {
          

 
$("#commentsubmit").click(function() {
var commentonlyc = $("#commentonlyc").val();
var useridcomment = $("#useridcomment").val();
var connectionidcomment = $("#connectionidcomment").val();

var dataString = 'commentonlyc='+ commentonlyc + '&useridcomment=' + useridcomment + '&connectionidcomment=' + connectionidcomment ;

if(commentonlyc=='' || useridcomment=='' || connectionidcomment=='')
{
$('.successc').fadeOut(200).hide();
$('.errorc').fadeOut(200).show();
}
else
{
$.ajax({
type: "POST",
url: "templates/formhandler.php",
data: dataString,
success: function(){
$('.successc').fadeIn(200).show();
$('.errorc').fadeOut(200).hide();
}
});
}
return false;
});
});



</script>
<script src="/public/view/javascript/Ajax.js"></script>

<script>
      $(function() {
$("#rate1").click(function() {
    var rate = 'rate1';
          ajax.owrAjax(rate);
});
});
 $(function() {
$("#rate2").click(function() {
    var rate = 'rate2';
          ajax.owrAjax(rate);
});
});
 $(function() {
$("#rate3").click(function() {
    var rate = 'rate3';
          ajax.owrAjax(rate);
});
});
 $(function() {
$("#rate4").click(function() {
    var rate = 'rate1';
          ajax.owrAjax(rate);
    
});
});
 $(function() {
$("#rate5").click(function() {
    var rate = 'rate5';
          ajax.owrAjax(rate);

});
});
 $(function() {
$("#rate6").click(function() {
    var rate = 'rate6';
          ajax.owrAjax(rate);
});
});
 $(function() {
$("#rate7").click(function() {
    var rate = 'rate7';
          ajax.owrAjax(rate);    
});
});
 $(function() {
$("#rate7").click(function() {
    var rate = 'rate7';
          ajax.owrAjax(rate);
});
});
 $(function() {
$("#rate8").click(function() {
    var rate = 'rate8';
          ajax.owrAjax(rate);
});
});
 $(function() {
$("#rate9").click(function() {
    var rate = 'rate9';
          ajax.owrAjax(rate);

});
});
 $(function() {
$("#rate10").click(function() {
    var rate = 'rate10';
          ajax.owrAjax(rate);
 
});
});
 
</script>

<script>
$(document).ready(function(){
     var auto_refresh = 0;
    $('#commentsshow2').load('templates/showcomments.php?id=<?php echo $connid?>').fadeIn("slow");
   
 $('#sortlike').click(function() {
           $('#commentsshow1').hide();
           $('#commentsshow2').hide();
           clearInterval(auto_refresh);
           $('#commentsshow').load('templates/showcomments1.php?id=<?php echo $connid?>').fadeIn("slow");
            auto_refresh = setInterval( function (){
    
    $('#commentsshow').load('templates/showcomments1.php?id=<?php echo $connid?>').fadeIn("fast");
}, 30000); // refresh every 10000 milliseconds
         });
 
 $('#sortdislike').click(function() {
         $('#commentsshow').hide();
           $('#commentsshow2').hide();
           clearInterval(auto_refresh);
           $('#commentsshow1').load('templates/showcomments2.php?id=<?php echo $connid?>').fadeIn("slow");
            auto_refresh = setInterval(function (){

$('#commentsshow1').load('templates/showcomments2.php?id=<?php echo $connid?>').fadeIn("fast");
}, 30000); // refresh every 10000 milliseconds
          
       });
         
$('#sortlikeordinary').click(function() {
           $('#commentsshow').hide();
           $('#commentsshow1').hide();
           clearInterval(auto_refresh);
     
        $('#commentsshow2').load('templates/showcomments.php?id=<?php echo $connid?>').fadeIn("slow");
            auto_refresh = setInterval(function (){
    

$('#commentsshow2').load('templates/showcomments.php?id=<?php echo $connid?>').fadeIn("fast");
}, 30000); // refresh every 10000 millisecond
         });     
 });
 
</script>

<script>
    
    $(document).ready(function(){
$('#showrate').load('templates/showrating.php?id=<?php echo $connid?>').fadeIn("slow");

     var auto_refresh = 0;
$('#bar').click(function() {
         $('#showpie').hide();
         $('#showgraph').hide();
         $('#showrate').load('templates/showrating.php?id=<?php echo $connid?>').fadeIn("slow");
         clearInterval(auto_refresh);
         auto_refresh = setInterval(function (){
         
         
         $('#showrate').load('templates/showrating.php?id=<?php echo $connid?>');
            }, 500);
        });
        
$('#pie').click(function() {
         $('#showrate').hide();
         $('#showgraph').hide();
         $('#showpie').load('templates/showSexPercentage.php?id=<?php echo $connid?>').fadeIn("slow");
         clearInterval(auto_refresh);
         auto_refresh = setInterval(function (){
         
         $('#showpie').load('templates/showSexPercentage.php?id=<?php echo $connid?>');
            }, 15000);
        });   
        
 $('#graph').click(function() {
         $('#showrate').hide();
         $('#showpie').hide();
         $('#showgraph').load('templates/viewGraph.php?id=<?php echo $connid?>').fadeIn("slow");
         clearInterval(auto_refresh);
         auto_refresh = setInterval(function (){
         
         $('#showgraph').load('templates/viewGraph.php?id=<?php echo $connid?>');
            }, 15000);
        });        
        
        
        });
</script>


    


</head>

    <body>
                

    <!-- Define Header -->
        <header>

             <?php include('view/templates/header.php');?>
            
        
        </header>
    <!-- End Header -->
    <!-- Define Navigation/Menu -->

        <nav>
   
             <?php include('view/templates/nav.php');?>
    
        </nav>
    <!-- End Navigation -->
    <!-- Main content area -->
    <section>
        <?php if (!isset($_GET['id'])){
            include('view/templates/listall.php');
        }else{
?>
        <?php
        $getid = $_GET['id'];
        $findbyid = Company_Product::Find_by_id($getid);
        
         if($findbyid->company_id!=0){      include('view/admin/templates/showcompany.php');}
         if($findbyid->product_id!=0){      include('view/admin/templates/showproduct.php');}
         
        }
        ?>
        
        
        <div id="stats">
           
            <img src="view/images/bar.png"    id="bar"    width="25"     height="25">
            <img src="view/images/graph.png"  id="graph"  width="25"     height="25">
            <img src="view/images/pie.png"    id="pie"    width="25"     height="25">
            <hr>
            <div id="showrate"></div>

            <div id="showpie"></div>

            <div id="showgraph"></div>
            
        </div>
        

        
        
        <div id="commentsshow"></div>
        <div id="commentsshow1"></div>
        <div id="commentsshow2"></div>
        
        
        
            
    </section>
    <!-- End of Main content area -->

    

    <!-- Sidebar -->
        <aside>
        </aside>
    <!-- End Sidebar -->
    <!-- Footer -->
    <footer>
  

 <?php include('view/templates/footer.php');?>

    </footer>
     
          
    <!-- End of Footer -->
        
        <!-- End of Total--->
   </body>
 </html>
